package com.sg.bars.server.kernel.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;

import com.sg.bars.client.kernel.action.Action;
import com.sg.bars.client.kernel.action.ActionException;
import com.sg.bars.client.kernel.service.DataService;

public class DataServiceImpl implements DataService {
	private static final long serialVersionUID = -6152021688076581L;

	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	private ActionQueryFactory actionQueryFactory;
	private ActionQueryRunner actionQueryRunner;


	@Override
	public Object doAction(Action action) throws ActionException {
		AbstractActionQuery actionQuery = getActionQueryFactory()
		    .resolveActionQuery(action);
		return getActionQueryRunner().doActionQuery(actionQuery);
	}

	public void setActionQueryFactory(ActionQueryFactory actionQueryResolver) {
		this.actionQueryFactory = actionQueryResolver;
	}

	public ActionQueryFactory getActionQueryFactory() {
		return actionQueryFactory;
	}

	@Required
	public void setActionQueryRunner(ActionQueryRunner actionQueryRunner) {
		this.actionQueryRunner = actionQueryRunner;
	}

	@Required
	public ActionQueryRunner getActionQueryRunner() {
		return actionQueryRunner;
	}

}
